home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.util.Date;
- import symjava.sql.SQLException;
- import symjava.sql.Time;
- import symjava.sql.Timestamp;
-
- class NetTime extends DateTimeField {
- Time _timeVal;
-
- int getType() {
- return 76;
- }
-
- void readData(DataInputStream is) throws SQLException, IOException, ErrorException {
- int iHour = 0;
- ServerObject obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iHour = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iMinutes = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iMinutes = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iSeconds = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iSeconds = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- this._timeVal = new Time(iHour, iMinutes, iSeconds);
- }
-
- void writeData(DataOutputStream os) throws IOException {
- NetData data = new NetData((short)this._timeVal.getHours());
- data.write(os);
- data = new NetData((short)this._timeVal.getMinutes());
- data.write(os);
- data = new NetData((short)this._timeVal.getSeconds());
- data.write(os);
- }
-
- public String getString() throws SQLException {
- return ((Field)this).isNull() ? null : this._timeVal.toString();
- }
-
- public Time getTime() throws SQLException {
- return ((Field)this).isNull() ? null : this._timeVal;
- }
-
- public void setString(String x) throws SQLException {
- this._timeVal = Time.valueOf(x);
- super._null = false;
- }
-
- public void setTime(Time x) throws SQLException {
- this._timeVal = x;
- super._null = false;
- }
-
- public void setTimestamp(Timestamp x) throws SQLException {
- this._timeVal = new Time(((Date)x).getHours(), ((Date)x).getMinutes(), ((Date)x).getSeconds());
- super._null = false;
- }
-
- public int getSQLType() {
- return 92;
- }
-
- public Object getObject() throws SQLException {
- return new Time(this._timeVal.getHours(), this._timeVal.getMinutes(), this._timeVal.getSeconds());
- }
-
- public void setObject(Object obj) throws SQLException {
- this.setTime((Time)obj);
- }
- }
-